var setting = window.opener.setting;
var para = window.opener.para;
var invisibleDiv = document.getElementById("invisibleDIV");
var maintext = document.getElementById("maintext");
var boddy = document.getElementById("woshimaojiajun");
var musicorder = window.opener.musicorder;
var speed = 150;
var end = false;
if (setting[0] == 1) {
	invisibleDiv.innerHTML = musicorder;
}

// maintext.innerHTML = para[0];

// 拿到了一个para数组
// 下标n表示第n+1段
// 需要做的是，单击一次，缓慢输出一段
// time定时器内累加计数器
// 每段结束（即计数器=para[i].length()）时para+=1，然后计数器请0

var counter = 0;
var paras = 0;
var showtext = "";

function clock() {
	console.log(counter);
	if (paras <= 7) {
		if (counter <= para[paras].length) { //当计数器小于段落总长时，推进文章
			showtext += para[paras].charAt(counter);
			maintext.innerHTML = showtext;
			counter++;
		} else {
			showtext += "<br><p class='spacetext'>";
			maintext.innerHTML = showtext;
			time = window.clearInterval(time);
			counter = 0;
			paras++;
		}
	} else {
		end = true;
		showtext += "ending.....";
		maintext.innerHTML = showtext;
		time = window.clearInterval(time);
	}
}
var time = self.setInterval("clock()", speed);

boddy.onclick = function() {
	if (time == undefined && end == false) {
		time = self.setInterval("clock()", speed);
	}
}
// time = window.clearInterval(time)
